package com.fau.wmbj.server.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.vladmihalcea.hibernate.type.json.JsonStringType;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.TypeDef;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;

/**
 * 管理员
 *
 * @author jiawei
 * @version 1.0
 * @datetime 2024-02-20 15:57
 */
@Getter
@Setter
@Entity(name = "f_user")
@TypeDef(name = "json", typeClass = JsonStringType.class)
public class User extends BaseEntity<Long> {

    /**
     * 是否启用
     */
    @Column(name = "enabled_")
    private Boolean enabled;

    /**
     * 手机号码
     */
    @Column(name = "phone_num", unique = true)
    private String phoneNumber;

    /**
     * 加密密码
     */
    @JsonIgnore
    @Column(name = "encrypted_pwd")
    private String encryptedPassword;

    /**
     * 邮箱
     */
    @NotBlank
    @Column(name = "email", unique = true, nullable = false)
    private String email;

    /**
     * 头像
     */
    @Column(name = "avatar")
    private String avatar;

    /**
     * 姓名
     */
    @Column(name = "nick_name")
    private String nickName;

    /**
     * 角色
     */
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "role_id")
    private Role role;

    @Transient
    private String password;
    @Transient
    private String username;
    @Transient
    private Boolean rememberMe = false;
}
